package top.malaoshi.jdbc;

import java.sql.Connection;
import java.sql.SQLException;

public class DbSessionFactory {

    public static DbSession newSession(String driver, String url, String username, String password) throws SQLException, ClassNotFoundException {

        return newSession(driver, url, username, password,true);
    }

    public static DbSession newSession(String driver, String url, String username, String password, boolean autoCommit) throws ClassNotFoundException, SQLException{
        Connection connect = ConnectionFactory.connect(driver, url, username, password,autoCommit);
        Db db = new DbImpl(connect);

        DbSession session = new DbSessionImpl(db);

        return session;
    }
}
